#include <iostream>
#include <stack>
#include <vector>
using namespace std;

bool checkPop(vector<int> poped) {
    stack<int> st;
    for (int i = 0, j = 0; i < poped.size(); ++i) {
        st.emplace(i+1);
        cout << st.top() << "入栈" << endl;
        while (!st.empty() && st.top() == poped[j]) {
            cout << st.top() << "出栈" << endl;
            st.pop();
            ++j;
        }
    }
    return st.empty();
}

int main(void) {
    int num;
    cout << "判断几的出栈序列？" << endl;
    cin >> num;
    vector<int> poped;
    for (int i = 0; i < num; ++i) {
        int cur;
        cin >> cur;
        poped.push_back(cur);
        // cout << poped[i];
    }
    bool ans = checkPop(poped);
    if (ans) {
        cout << "序列正确" << endl;
    }else {
        cout << "序列不正确" << endl;
    }

    return 0;
}